import Vue from 'vue'
import VueRouter from 'vue-router'
import VueCookies from "vue-cookies"


Vue.use(VueRouter)

const routes = [
  {
    // 重定向
    path: '/',
    redirect: '/index'
  },
  {
    name:'login',
    path: '/login',
    component: () => import('../views/login.vue')
  },
  {
    name:'index',
    path: '/index',
    component: () => import('../views/index.vue')
  },
  {
    name:'home',
    path: '/home',
    // redirect: 'searchDetail',
    component: () => import('../views/home.vue')
  }
]

const router = new VueRouter({
  routes
})

// 路由守卫
router.beforeEach((to, from, next) => {
  if (to.path == '/login') {
    next()
  } else {
    console.log(VueCookies)
    next()
  }
})




export default router
